<?php

function simple_ways_autocomplete($column, $filter = '') {
    $CI =& get_instance();
    $sql = 'SELECT ' . $CI->db->protect_identifiers($column) . ' FROM `odcestovani` WHERE ' . $CI->db->protect_identifiers($column) . ' LIKE \'%' . $CI->db->escape_like_str($filter) . '%\'';
    $sql .= ' UNION DISTINCT ';
    $sql .= 'SELECT ' . $CI->db->protect_identifiers($column) . ' FROM `pricestovani` WHERE ' . $CI->db->protect_identifiers($column) . ' LIKE \'%' . $CI->db->escape_like_str($filter) . '%\'';
    $query = $CI->db->query($sql);
    $data = array();
    if ($query->num_rows() > 0) { foreach ($query->result() as $row) {
        $data[] = $row->$column;
    }}
    return $data;
}

function simple_people_autocomplete($column, $filter = '') {
    $CI =& get_instance();
    $sql = 'SELECT DISTINCT ' . $CI->db->protect_identifiers($column) . ' FROM `people` WHERE ' . $CI->db->protect_identifiers($column) . ' LIKE \'%' . $CI->db->escape_like_str($filter) . '%\'';
    $query = $CI->db->query($sql);
    $data = array();
    if ($query->num_rows() > 0) { foreach ($query->result() as $row) {
        $data[] = $row->$column;
    }}
    return $data;
}